package edu.xy.hm02_01.slice;

import edu.xy.hm02_01.ResourceTable;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Button;
import ohos.agp.components.Component;

public class MainAbilitySlice extends AbilitySlice {
    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        // 设置该页面所关联的页面布局
        super.setUIContent(ResourceTable.Layout_ability_main);

        // 获取按钮对象
        Button button_01 = (Button)this.findComponentById(ResourceTable.Id_button_main_01);

        // 给按钮对象设置单击事件
        button_01.setClickedListener(this::clickedListenerButton01);


        // 获取按钮对象
        Button button_02 = (Button)this.findComponentById(ResourceTable.Id_button_main_02);

        // 给按钮对象设置单击事件
        button_02.setClickedListener(this::clickedListenerButton02);



        // 获取按钮对象
        Button button_03 = (Button)this.findComponentById(ResourceTable.Id_button_main_03);

        // 给按钮对象设置单击事件
        button_03.setClickedListener(this::clickedListenerButton03);



        // 获取按钮对象
        Button button_04 = (Button)this.findComponentById(ResourceTable.Id_button_main_04);

        // 给按钮对象设置单击事件
        button_04.setClickedListener(this::clickedListenerButton04);



        // 获取按钮对象
        Button button_05 = (Button)this.findComponentById(ResourceTable.Id_button_main_05);

        // 给按钮对象设置单击事件
        button_05.setClickedListener(this::clickedListenerButton05);

    }

    private void clickedListenerButton05(Component component) {
        // 创建意图对象
        Intent intent = new Intent();
        this.present(new MainAbilitySlice_05(),intent);
    }

    private void clickedListenerButton04(Component component) {
        // 创建意图对象
        Intent intent = new Intent();
        this.present(new MainAbilitySlice_04(),intent);
    }

    private void clickedListenerButton03(Component component) {
        // 创建意图对象
        Intent intent = new Intent();
        this.present(new MainAbilitySlice_03(),intent);
    }

    private void clickedListenerButton02(Component component) {
        // 创建意图对象
        Intent intent = new Intent();
        this.present(new MainAbilitySlice_02(),intent);
    }

    // 跳转到第一个页面
    private void clickedListenerButton01(Component component) {
        // 创建意图对象
        Intent intent = new Intent();
        this.present(new MainAbilitySlice_01(),intent);
    }

    @Override
    public void onActive() {
        super.onActive();
    }

    @Override
    public void onForeground(Intent intent) {
        super.onForeground(intent);
    }
}
